package com.zdp.seckill.common.exception;

import com.zdp.seckill.common.constant.ApiConstant;
import com.zdp.seckill.common.enums.EmBusinessError;
import lombok.Getter;
import lombok.Setter;

/**
 * 全局异常类
 */
@Getter
@Setter
public class BusinessException extends RuntimeException {

    private Integer errorCode;

    public BusinessException() {
        super(ApiConstant.ERROR_MESSAGE);
        this.errorCode = ApiConstant.ERROR_CODE;
    }

    public BusinessException(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public BusinessException(String message) {
        super(message);
        this.errorCode = ApiConstant.ERROR_CODE;
    }

    public BusinessException(Integer errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public BusinessException(EmBusinessError emBusinessError){
        super(emBusinessError.errMsg);
        this.errorCode = emBusinessError.errCode;
    }

}